class ResponseDataModel<T> {
  int code;
  T data;
  String msg;

  ResponseDataModel({this.code, this.data, this.msg});

  factory ResponseDataModel.fromJson(Map<String, dynamic> json) {
    print(json);
    return ResponseDataModel(
      code: json['code'],
      data: json['data'],
        msg: json['msg'] == "User has not logged in yet"
            ? "账户已在其他设备登录，请重新登录"
            : json['msg']//== "success" ? "成功" : json['msg'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    if (this.data != null) {
      data['data'] = this.data;
    }
    data['msg'] = this.msg;
    return data;
  }

  bool success() {
    print("success() $msg");
    return this.msg == 'SUCCESS' || this.msg == 'success';//|| this.msg == '成功';
  }

// ResponseDataMode.fromJson(Map<String, dynamic> json, dynamic dy) {
//   ResponseDataMode(
//     code: json['code'],
//     data: dy,
//     msg: json['msg'],
//   );
// }
}

abstract class DataMode {
  DataMode.fromJson(Map<String, dynamic> json);
}
